﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls"
    xmlns:ComponentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase">

    <!-- BEGIN SinacorExplorer -->
    <Style TargetType="{x:Type Controls:SinacorExplorer}">
        <!--<Style.Resources>

            <Style TargetType="{x:Type Controls:SinacorTextBlock}" />
            <Style TargetType="{x:Type Controls:SinacorLabel}" />

        </Style.Resources>-->

        <Setter Property="IsItemDetailsVisible" Value="False" />
        
        <Setter Property="GroupsWidth" Value="1*" />
        <Setter Property="ViewsWidth" Value="3*" />

        <Setter Property="ViewsHeight" Value="2*" />
        <Setter Property="ViewsMinHeight" Value="35" />
        <Setter Property="ItemDetailsHeight" Value="1*" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:SinacorExplorer}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="{Binding GroupsWidth, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" MinWidth="{TemplateBinding GroupsMinWidth}" MaxWidth="{TemplateBinding GroupsMaxWidth}" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="{Binding ViewsWidth, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" MinWidth="{TemplateBinding ViewsMinWidth}" MaxWidth="{TemplateBinding ViewsMaxWidth}" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <!-- Groups -->
                        <Border x:Name="PART_Groups" Grid.Row="0" Grid.Column="0" Margin="2" Padding="4" SnapsToDevicePixels="True" BorderBrush="{DynamicResource BrushTreeViewBorder}" BorderThickness="1" CornerRadius="3" Background="{DynamicResource BrushTreeViewBackground}">
                            <Border.Resources>

                                <Style TargetType="{x:Type Controls:SinacorTreeView}" BasedOn="{StaticResource FolderTreeView}">
                                    <Style.Setters>
                                        <Setter Property="BorderThickness" Value="0" />
                                        <Setter Property="Padding" Value="2,0" />
                                    </Style.Setters>
                                </Style>

                            </Border.Resources>

                            <ContentPresenter ContentSource="Groups" />
                        </Border>

                        <Controls:SinacorVerticalGridSplitter Grid.Row="0" Grid.Column="1" />

                        <Grid Grid.Row="0" Grid.Column="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="{Binding ViewsHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" MinHeight="{TemplateBinding ViewsMinHeight}" MaxHeight="{TemplateBinding ViewsMaxHeight}" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="{Binding ItemDetailsHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" MinHeight="{TemplateBinding ItemDetailsMinHeight}" MaxHeight="{TemplateBinding ItemDetailsMaxHeight}" />
                            </Grid.RowDefinitions>

                            <!-- Views -->
                            <Border x:Name="PART_Views" Grid.Row="0" Grid.Column="0" Margin="2" SnapsToDevicePixels="True" BorderBrush="{DynamicResource BrushTreeViewBorder}" BorderThickness="1" CornerRadius="3" Background="{DynamicResource BrushTreeViewBackground}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>

                                    <Grid.Resources>

                                        <!-- BEGIN ExplorerView -->
                                        <Style TargetType="{x:Type Controls:ExplorerView}">
                                            <Style.Setters>
                                                <Setter Property="Visibility" Value="Collapsed" />
                                            </Style.Setters>
                                        </Style>

                                        <Style TargetType="{x:Type Controls:ExplorerListView}" BasedOn="{StaticResource {x:Type Controls:ExplorerView}}">
                                            <Style.Resources>
                                                <Style TargetType="{x:Type Controls:SinacorListView}" BasedOn="{StaticResource HorizontalListView}" />
                                            </Style.Resources>
                                        </Style>

                                        <Style TargetType="{x:Type Controls:ExplorerDetailsView}" BasedOn="{StaticResource {x:Type Controls:ExplorerView}}" />
                                        <!-- END ExplorerView -->

                                    </Grid.Resources>

                                    <!-- ViewDescriptions -->
                                    <Controls:SinacorComboBox x:Name="PART_ViewDescriptionsComboBox" 
                                                          SelectedValuePath="Name" 
                                                          DisplayMemberPath="Header" 
                                                          SelectedValue="{Binding SelectedView, RelativeSource={RelativeSource TemplatedParent}}"
                                                          ItemsSource="{Binding ViewDescriptions, RelativeSource={RelativeSource TemplatedParent}}" 
                                                          Grid.Column="0" Grid.Row="0" Margin="4,4,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" 
                                                          Width="155" IsRequired="True" />

                                    <!-- NavigationPath -->
                                    <ContentPresenter x:Name="PART_NavigationPath" ContentSource="NavigationPath" 
                                                Grid.Column="1" Grid.Row="0" Margin="4,4,4,0" HorizontalAlignment="Stretch" VerticalAlignment="Center" />

                                    <!-- View -->
                                    <ItemsControl x:Name="PART_ViewsItemsControl" 
                                              ItemsSource="{Binding Views, RelativeSource={RelativeSource TemplatedParent}}" 
                                              Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="4,4,4,4">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <Grid />
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                    </ItemsControl>
                                </Grid>
                            </Border>

                            <Controls:SinacorHorizontalGridSplitter x:Name="PART_ItemDetailsHorizontalSplitter" Visibility="Visible" Grid.Row="1" Grid.Column="0" />

                            <!-- ItemDetails -->
                            <Border x:Name="PART_ItemDetails" Visibility="Visible" Grid.Row="2" Grid.Column="0" Margin="2" Padding="4" SnapsToDevicePixels="True" BorderBrush="{DynamicResource BrushTreeViewBorder}" BorderThickness="1" CornerRadius="3" Background="{DynamicResource BrushTreeViewBackground}">
                                <ContentPresenter ContentSource="ItemDetails" />
                            </Border>
                        </Grid>

                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsItemDetailsVisible" Value="False">
                            <Setter TargetName="PART_ItemDetailsHorizontalSplitter" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_ItemDetails" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="CanChangeSelectedView" Value="False">
                            <Setter TargetName="PART_ViewDescriptionsComboBox" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="NavigationPath" Value="{x:Null}" />
                                <Condition Property="NavigationPathStringFormat" Value="{x:Null}" />
                                <Condition Property="NavigationPathTemplate" Value="{x:Null}" />
                                <Condition Property="NavigationPathTemplateSelector" Value="{x:Null}" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_NavigationPath" Property="Visibility" Value="Collapsed" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="CanChangeSelectedView" Value="False" />
                                <Condition Property="NavigationPath" Value="{x:Null}" />
                                <Condition Property="NavigationPathStringFormat" Value="{x:Null}" />
                                <Condition Property="NavigationPathTemplate" Value="{x:Null}" />
                                <Condition Property="NavigationPathTemplateSelector" Value="{x:Null}" />
                            </MultiTrigger.Conditions>
                            <Setter Property="ViewsMinHeight" Value="0" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- END SinacorExplorer -->

</ResourceDictionary>